<?php


namespace App\Command\Cron;


use App\Entity\Page;
use App\Enum\CommandEnum;
use App\Utils\Helper\GetterHelper;
use MyBuilder\Bundle\CronosBundle\Annotation\Cron;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

/**
 * Class DefaultCommand
 * @package App\Command\Crontab
 * @Cron(minute="0", noLogs=true, server="web")
 * @Cron(minute="30", noLogs=true, server="web")
 */
class PublishPageCommand extends Command {

    protected static $defaultName = 'cron:publish-page';

    protected function configure () {
        $this->setDescription('每整点和半点时执行一次定时发布任务');
    }

    protected function execute (InputInterface $input, OutputInterface $output) {
        GetterHelper::getEntityManager()->getRepository(Page::class)->publishPageByCron();
        return CommandEnum::SUCCESS;
    }
}